home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Environments / Chipmunk Basic 3.5.2 / basic.man next >
Text File  |  1996-09-05  |  30KB  |  1,092 lines

  1. <HTML>
  2. <HEAD>
  3. <TITLE>Chipmunk Basic Man Page</TITLE>
  4. <H1>Chipmunk Basic Man Page</H1>
  5. </HEAD>
  6. <BODY>
  7. <HR>
  8. <PRE>
  9.  
  10.     BASIC(1)        chipmunk-basic v3.5.0             BASIC(1)
  11.  
  12.  
  13.     Chipmunk BASIC - 'BASIC' language interpreter
  14.     
  15.  
  16.     SYNOPSIS    ( UNIX )
  17.  
  18.     basic [ filename ]
  19.  
  20.     DESCRIPTION
  21.  
  22.     Chipmunk basic is an interpreter for the BASIC language. If
  23.     a filename parameter is given, then the named program file
  24.     is loaded into memory and run.  
  25.  
  26.     Basic commands and statements can be entered and interpreted
  27.     in immediate mode or executed as program statements when the
  28.     Basic program is run.  A built-in line number based editor
  29.     allows program input from the console keyboard.  See below
  30.     for the commands and statements that the interpreter
  31.     recognizes.
  32.     
  33.     FLAGS
  34.  
  35.     none
  36.  
  37.     COMMANDS
  38.         
  39.     Standard mumbleSoft-like Basic Commands:
  40.  
  41.     load STRINGEXPR
  42.  
  43.         Load a program into memory from the named file. The
  44.         program previously in memory is erased.  All files are
  45.         closed and all variables are cleared.  Lines beginning
  46.         with the '#' character will be treated as comments. 
  47.         All other lines in the file must begin with a line
  48.         number.  Duplicate line numbers are not allowed.
  49.  
  50.  
  51.     save STRINGEXPR
  52.  
  53.         Save the current program to the named file.
  54.  
  55.     new
  56.  
  57.         Erase the program in memory.  All files are closed and
  58.         all variables are cleared.
  59.  
  60.     clear
  61.  
  62.         All  variables are cleared.  All arrays and string
  63.         variables are deallocated.
  64.  
  65.     run { LINENUM }
  66.     run { STRINGEXPR { , LINENUM } }
  67.  
  68.         Begin execution of the program at the first line, or at
  69.         the specified line.  All variables are cleared.  If a
  70.         STRINGEXPR is given then the BASIC program with that
  71.         name file is loaded into memory first.  Program lines
  72.         are executed in line number order.
  73.  
  74.     cont
  75.  
  76.         CONTinue execution of the program on the next statement
  77.         after the statement on which the program stopped
  78.         execution due to a STOP command or an error.  See BUGS
  79.         section.
  80.  
  81.     LINENUM { TEXT }
  82.     
  83.         Enters a program line.  If a program line with
  84.         line number LINENUM exists, then it is replaced.
  85.         If no TEXT is given, the the program line with
  86.         line number LINENUM is deleted.
  87.     
  88.     list
  89.         List the whole program.
  90.         Line numbers above 999999999 will not list.
  91.  
  92.     list 1-3
  93.         List lines 1 to 2
  94.  
  95.     list -2
  96.         List lines up to 1
  97.  
  98.     list 1
  99.         List line 1
  100.     
  101.     list 2-
  102.         List lines from 2 on
  103.  
  104.     merge STRINGEXPR
  105.  
  106.         Loads a program into memory.  The previous program
  107.         remains in memory; variables are not cleared.  If a
  108.         line exists in both programs, the new merged line
  109.         overwrites the old one.
  110.  
  111.     renum STRINGEXPR VAL { , VAL { , VAL { , VAL} } }
  112.  
  113.         Renumber program lines.  By default, the new sequence is
  114.         10,20,30,... The first argument is a new initial line
  115.         number; the second argument is the increment between
  116.         line numbers. The third and fourth arguments, if
  117.         present, specify a limiting range of old line numbers
  118.         to renumber.  RENUM can be used to move non-overlapping
  119.         blocks of code.
  120.      
  121.     edit LINENUM
  122.  
  123.         Edit a single line. If the exit from the edit is via a
  124.         cntrl-c then do not change the line.
  125.             i    insert till <return>
  126.             x    delete one char
  127.             A    append to end of line
  128.  
  129.     del LINENUM [ - LINENUM ]
  130.  
  131.         Delete a line or specified range of lines. If not found
  132.         then no lines will be deleted.
  133.  
  134.     exit
  135.     bye
  136.     quit
  137.  
  138.         Terminates the basic interpreter, ending program
  139.         execution and closing all files.
  140.  
  141.  
  142.     STATEMENTS
  143.  
  144.     { let } VAR = EXPR
  145.  
  146.         Assign a value to a variable.  Variable names can be up
  147.         to 31 significant characters, consisting of letters,
  148.         digits, underscores, and an ending dollar sign.
  149.         Variable names are case insensitive.  Variables can
  150.         hold real numbers (IEEE double) or strings of up to 254
  151.         characters.  If the variable name ends with a "$" it
  152.         holds strings, otherwise it holds numbers.  If a
  153.         statement starts with a variable name then an implied
  154.         LET is assumed.
  155.  
  156.     print  VAL | STRINGVAL { [ , | ; ] VAL ... } { ; }
  157.     ?      VAL | STRINGVAL { [ , | ; ] VAL ... } { ; }
  158.     print # FNUM, VAL ...
  159.  
  160.         This command will print its parameters tab delimited.
  161.         If a semi-colon is used between parameters then no tab
  162.         is inserted between the parameters.  The print
  163.         output is terminated with a carriage return unless the
  164.         parameter list ends with a semi-colon.  If a file
  165.         descriptor is given then output is redirected to the
  166.         given file.  If a
  167.         
  168.             tab(VAL);
  169.             
  170.         is found in a print statement, then print output will
  171.         skip to the horizontal position specified by VAL.
  172.  
  173.     print { # FNUM, } using STRINGVAL ; VAR { [ , | ; ] VAR ... }
  174.     
  175.         Prints formatted numbers.  Legal characters for the
  176.         format string STRINGVAL are: + * $ # . E+ and trailing
  177.         spaces.
  178.         
  179.         Examples:
  180.         
  181.             print using "**$###.##"; 1.23  :' ****$1.23
  182.             print using "###.##"; 2.12345  :'   2.12
  183.             print using "#.##E+##"; 2345.6 :'   2.35E+03
  184.             
  185.     input  STRINGVAR | VAR  { , VAR }
  186.     input  "prompt"; { STRINGVAR | VAR  { , VAR } }
  187.     input  { # FNUM , } { STRINGVAR | VAR { , VAR } }
  188.  
  189.         Input from the console or from the file specified by
  190.         FNUM. If the input is from the console then a prompt
  191.         string can optionally be printed.
  192.         
  193.         *** NOTE ***
  194.         
  195.         All input to string variables is "line input"; a whole
  196.         input line will be read into one string variable.  The
  197.         number of comma seperated numeric values in the input
  198.         data must be less than or equal to the number of
  199.         numeric variables in the INPUT statement.  This INPUT
  200.         usage is different from other versions Basic.
  201.  
  202.     get STRINGVAR
  203.     
  204.         Gets one character from the console keyboard.  Blocking.
  205.     
  206.     fputbyte VAL, # FNUM
  207.     
  208.         Writes one byte to the file specified by FNUM.
  209.     
  210.     get # FNUM, VAL, TYPED-VAR
  211.     
  212.         Reads one record from a random access file into VAR.
  213.     
  214.     put # FNUM, VAL, TYPED-VAR
  215.     
  216.         Write one record to a random access file from VAR.
  217.     
  218.     cls
  219.         Clear the terminals screen.  Leaves the cursor in the
  220.         upper left corner.  For Applesoft BASIC fans, the
  221.         "home" command will also do this.
  222.  
  223.     end
  224.  
  225.         Terminates program execution and returns to the command
  226.         prompt.  Not required.
  227.  
  228.     stop
  229.  
  230.         Stops the execution of the program and returns to
  231.         the command prompt.  Prints a "Break..." message.
  232.  
  233.     if EXPR then STATEMENT { : STATEMENT } { : else STATEMENT }
  234.     if EXPR then LINENUM
  235.     if EXPR
  236.  
  237.         The IF statement.  If the condition is true then the
  238.         STATEMENTS after the THEN are executed and the
  239.         statements after the ELSE are skipped.  If the
  240.         condition is false then the statements after the "else"
  241.         are executed instead.  If the item after "then" is a
  242.         line number then a goto is executed.
  243.         
  244.         If the condition is true and there is no THEN on the
  245.         same line, statements are executed until a line
  246.         with an ENDIF is found.  (block IF() ... ENDIF)
  247.  
  248.     for VAR = EXPR to EXPR { step EXPR }
  249.  
  250.         Beginning of a FOR-NEXT loop.  It takes a starting
  251.         value, a limit and an optional step argument.  If the
  252.         step value is negative, the variable counts down.  The
  253.         body of the loop is not executed if the end condition
  254.         is true initially.
  255.  
  256.         Example:
  257.             for i=1 to 10 : print i, : next i
  258.             rem prints the numbers from 1 through 10
  259.  
  260.     next { VAR }
  261.  
  262.         End of a FOR-NEXT loop.  If the termination conditions
  263.         are met then execution falls through to the following
  264.         statement, otherwise execution returns to the statement
  265.         following the FOR statement with the corresponding
  266.         index variable. If there no index variable parameter,
  267.         the innermost FOR loop is used.
  268.  
  269.     exit for
  270.  
  271.         Exits the current FOR-NEXT loop.
  272.         
  273.     while { EXPR }
  274.  
  275.         Start of a WHILE loop. The loop is repeated until EXPR
  276.         is false. If EXPR is false at loop entry, then the loop
  277.         is not executed . A WHILE loop must be terminated by a
  278.         balancing WEND statement.
  279.  
  280.     wend { EXPR }
  281.  
  282.         Terminating statement of a WHILE loop.  If EXPR is true
  283.         then exit the loop.  Only one WEND is allowed for each
  284.         WHILE.  A WHILE-WEND loop without a condition will loop
  285.         forever.
  286.  
  287.     exit while
  288.  
  289.         Exits the current WHILE-WEND loop.
  290.         
  291.     gosub LINENUM
  292.  
  293.         Transfer command to a line number. Save return address
  294.         so that the program can resume execution at the
  295.         statement after the "gosub" command.  The recursion
  296.         depth is limited only by available memory.
  297.  
  298.     return
  299.  
  300.         Returns from the most recently activated subroutine
  301.         call (which must have been called by GOSUB).
  302.  
  303.     goto LINENUM
  304.  
  305.         This statement will transfer control to the line number
  306.         specified.  If the program is not running, then this
  307.         command will begin execution at the specified line
  308.         without clearing the variables.  An "Undefined line"
  309.         error will occur if LINENUM doesn't exist in the
  310.         program.
  311.  
  312.     on EXPR   goto  LINENUM { , LINENUM ... }
  313.     on EXPR   gosub LINENUM { , LINENUM ... }
  314.         This command will execute either a goto or a gosub to
  315.         the specified line number indexed by the value of EXPR.
  316.         If EXPR is larger than the number of LINENUMs, then
  317.         control passes to the next statement.
  318.         
  319.     on error  goto  LINENUM
  320.  
  321.         If the error form is used, only one linenumber is
  322.         allowed.  LINENUM is the line to which control is
  323.         transferred if an error occurs.  A GOTO or CONT
  324.         statement can be used to resume execution.  An error
  325.         inside a named SUB subroutine cannot be resumed from
  326.         or CONTinued.
  327.  
  328.     sub NAME ( VAR { , VAR ... } }
  329.  
  330.         Subroutine entry.  May be called by a CALL statement or
  331.         by NAME. A SUB subroutine must be exited by a RETURN or
  332.         END SUB statement.  There should be only one RETURN or
  333.         END SUB statement per SUB definition.  The variables in
  334.         the VAR list become local variables. String and numeric
  335.         arguments are passed by value; array arguments must be
  336.         pre-dimensioned and are passed by reference.
  337.         
  338.         Example:
  339.             110  x = foo (7, j)  : rem Pass 7 and j by value.
  340.             ...
  341.             2000 sub foo (x,y,z) : rem z is a local variable
  342.             2010   print x       : rem prints 7
  343.             ...
  344.             2080   foo = y+1     : rem return value
  345.             2090 end sub
  346.         
  347.         Subroutine definitions may not be nested.
  348.  
  349.  
  350.     select case EXPR
  351.     
  352.         Multi-way branch.  Executes the statements after
  353.         the CASE statement which matches the SELECT CASE
  354.         expression, then skips to the END SELECT statement.
  355.         If there is no match, and a CASE ELSE statement is
  356.         present, then execution defaults to the statements
  357.         following the CASE ELSE.
  358.         
  359.         Example:
  360.             200 select case x
  361.             210   case 2
  362.             ...
  363.             230   case 3, 4
  364.             ...
  365.             270   case else
  366.             ...
  367.             290 end select
  368.  
  369.  
  370.     dim VAR( d { , d { , d } } ) { , VAR( d { , d { , d } } ) }
  371.  
  372.         Dimension an array or list of arrays (string or numeric). 
  373.         A maximum of 4 dimensions can be used. The maximum
  374.         dimension size is limited by available memory. Legal
  375.         array subscripts are from 0 up and including the
  376.         dimension specified; d+1 elements are allocated.  All
  377.         arrays must be dimensioned before use.
  378.         
  379.         Example:
  380.             10 dim a(10)
  381.             20 for i=0 to 10
  382.             30   a(i) = i^2
  383.             40 next i
  384.             50 print a(5) : rem should print 25
  385.  
  386.     data ITEM { , ITEM }
  387.  
  388.         DATA statements contain the data used in the READ
  389.         statements. Items must be separated by commas.  The
  390.         items may be either numeric or string expressions,
  391.         corresponding to the type of variable being read.
  392.         Reading the wrong kind of object produces a "Type
  393.         mismatch" error.  Strings must be encapsulated with
  394.         quote marks.
  395.  
  396.     read VAR { , VAR }
  397.  
  398.         Read data from the DATA statements contained in the
  399.         program. List items can be either string or numeric
  400.         variables. Reading past the end the last DATA statement
  401.         generates an error.
  402.  
  403.     restore { LINENUM }
  404.  
  405.         The RESTORE statement causes the next READ to use the
  406.         first DATA statement in the program.  If a LINENUM is
  407.         given then the DATA statement on or after that
  408.         particular line is used next.
  409.  
  410.     rem or "`"
  411.  
  412.         A remark or comment statement.  Ignored by the program
  413.         during execution, however a REM statement can be the
  414.         target of a GOTO or GOSUB.
  415.  
  416.     open STRINGEXPR for { input|output|append } as # FNUM
  417.  
  418.         Open a file. The { input|output|append } parameter
  419.         specifies whether the file is to be read, written or
  420.         appended.  If STRINGEXPR is "stdin" for input or
  421.         "stdout" for output then the console will be used
  422.         instead of a file.  A "file not found" error will
  423.         occur if a non-existant file is specified in an OPEN
  424.         for input statement.  FNUM must be an integer value
  425.         between 0 and 8.
  426.  
  427.     open STRINGEXPR for random as # FNUM len = VAL
  428.  
  429.         Opens a random access file.  Only GET and PUT statement
  430.         are allowed to read and write random access files.
  431.  
  432.     open ... else goto LINENUM
  433.  
  434.         See OPEN command.
  435.         LINENUM is the line to which control is transferred if
  436.         an error in opening a file occurs.  The variable ERL is
  437.         set to the line number on which the file open error
  438.         occured.
  439.  
  440.     close # FNUM
  441.  
  442.         Close a file. Releases the file descriptor and flushes
  443.         out all stored data.
  444.  
  445.     def fnNAME ( VAR { , VAR } ) = EXPR
  446.  
  447.         Define a user definable function.  Obsolete.
  448.         
  449.         Example:
  450.             10 def fnplus(x,y) = x+y
  451.             20 print fnplus(3,5) : rem prints 8
  452.  
  453.     mat ARRAY-VAR = EXPR
  454.     
  455.         Fills a 1 or 2 dimensional array with a constant
  456.         value given by EXPR.
  457.  
  458.     mat ARRAY-VAR = ARRAY-VAR
  459.     
  460.         Copys a 2 dimensional array.  The dimensions
  461.         must match.
  462.  
  463.     mat ARRAY-VAR = transpose ARRAY-VAR
  464.     
  465.         Transposes a 2 dimensional array.  The dimensions of
  466.         the first array must correspond to the transpose of
  467.         the dimensions of the second array.
  468.  
  469.     mat ARRAY-VAR = ARRAY-VAR { + | * } { EXPR | ARRAY-VAR }
  470.     
  471.         Adds or multiplies a 2 dimensional array by either
  472.         an expression or another array.  The dimensions must
  473.         be appropriate for matrix addition or matrix
  474.         multiplication.
  475.  
  476.     mat origin { 0 | 1 }
  477.     
  478.         Sets the matrix index origin to either 0 or 1 for all
  479.         MAT statements, including fill.  Defaults to 0.
  480.  
  481.     type CLASSNAME
  482.     
  483.         Creates a structure definition type.  Each field
  484.         requires a separate line.  Legal types are string,
  485.         integer, longint and double.  The definition must
  486.         conclude with an END TYPE statement.  Use the
  487.         DIM AS NEW statement to create records containing
  488.         the structure specified by a TYPE statement.
  489.         
  490.         Example:
  491.             300 type person
  492.             310   name as string * 32 : rem = 31 chars length
  493.             320   age as integer      : rem  2 byte integers
  494.             330   weight as double      : rem  8 byte doubles
  495.             340 end type
  496.             400 dim friend1 as new person
  497.             410 friend1.name = "Mark" : friend1.age = 13
  498.             420 print friend1.name, friend1.age
  499.  
  500.  
  501.     class CLASSNAME { extends SUPERCLASSNAME }
  502.     
  503.         Creates a class definition.  Class definitions can then
  504.         be used to create objects with member functions (also
  505.         called methods.)  Classes inherit members from
  506.         superclasses (single inheritance.)
  507.         
  508.         Example:
  509.         CLASS bar
  510.           y AS integer
  511.           z AS PRIVATE double    ' private data
  512.           s AS PUBLIC string    ' public keyword optional
  513.           SUB blah(v)        ' public member function
  514.             this.y = v + 7
  515.           END SUB
  516.         END CLASS
  517.         
  518.         DIM b AS NEW bar    ' create object b
  519.         CALL b.blah(1)        ' send message "blah(1)" to b
  520.         
  521.         CLASS and TYPE definitions are global, and cannot be
  522.         nested inside other class definitions or subroutines.
  523.         
  524.     dim VAR { ( INT ) } as new CLASSNAME
  525.  
  526.         Create a record (TYPED-VAR) or object using a
  527.         previously defined structure definition type created
  528.         by TYPE...END TYPE or CLASS..END CLASS.  Optionally
  529.         creates an array of records or objects.
  530.         
  531.     erase VAR
  532.     
  533.         Un-dimensions a dimensioned array.  Frees memory.
  534.  
  535.     { let } mid$( STRINGVAR, EXPR1, EXPR2 ) = STRINGEXPR
  536.  
  537.         Replace the sub-string in STRINGVAR, starting at
  538.         character position EXPR1, with character length EXPR2,
  539.         with the (EXPR2 in length) string STRINGEXPR.
  540.  
  541.     { let } field$( STRINGVAR, VAL { ,STRINGVAL } ) = STRINGEXPR
  542.  
  543.         Replace the N-th field of STRINGVAR with STRINGEXPR.
  544.  
  545.     poke ADDR_EXPR, DATA_EXPR
  546.  
  547.         Poke a byte into a memory location. Unreasonable
  548.         addresses can cause bus or segmentation errors.
  549.  
  550.     push VAR { , VAR ... }
  551.  
  552.         Pushes one or more expressions or variables onto an
  553.         internal stack.  Expressions can be returned using the
  554.         POP function; variables can be returned by using the
  555.         POP statement.
  556.     
  557.     pop VAL
  558.  
  559.         POP statement (see also POP function). Pops VAL
  560.         variables off the internal stack, restoring the value
  561.         of those variables to their pushed values.
  562.     
  563.     exec(STRINGEXPR)
  564.  
  565.         Executes STRINGEXPR as a statement or command. 
  566.         e.g. exec("print " + "x") will print the value of x.
  567.  
  568.  
  569.     NUMERIC FUNCTIONS
  570.  
  571.     sgn(VAL)
  572.  
  573.         Returns the sign of the parameter value.  Returns 1 if
  574.         the value is greater than zero , zero if equal to zero.
  575.         -1 if negative.
  576.  
  577.     abs(x)
  578.  
  579.         Returns the absolute value of x.
  580.  
  581.     int(x)
  582.  
  583.         Returns the integer value of x.  Truncates toward zero.
  584.         The absolute value of x must be less than 2^31-1.
  585.  
  586.     floor(x)
  587.  
  588.         Returns the integer value of x.
  589.         Truncates toward negative infinity.
  590.  
  591.     sqr(x)
  592.  
  593.         Returns the square root of x.
  594.  
  595.     log(x)
  596.  
  597.         Returns the natural logarithm of x.
  598.  
  599.     log10(x)
  600.  
  601.         Returns the logarithm base 10 of x.
  602.  
  603.     exp(x)
  604.  
  605.         Returns e^x. e=2.7182818...
  606.  
  607.     sin(x)
  608.     cos(x)
  609.     atn(x)
  610.  
  611.         Trigonometric functions: sin, cosine and arctangent. 
  612.  
  613.     pi
  614.     
  615.         Returns pi, 3.141592653589793... 
  616.  
  617.     rnd ( EXPR )
  618.  
  619.         Returns an integer pseudo-random number between 0 and
  620.         int(EXPR)-1 inclusive. If EXPR is 1, then returns a
  621.         rational number between 0 (inclusive) and 1.  If EXPR
  622.         is negative then EXPR seeds the random number generator.
  623.  
  624.     randomize EXPR
  625.  
  626.         Seeds the random number generator with the integer
  627.         EXPR. The pseudo-random number generator should return
  628.         the same sequence when seeded with the same start
  629.         value.  The actual sequence may be system dependant.
  630.  
  631.     len( STRINGEXPR )
  632.  
  633.         Returns the length of the string STRINGEXPR.
  634.  
  635.     len( TYPED-VAR )
  636.  
  637.         Returns the length, in bytes, of a typed record
  638.         (one created by DIM AS).
  639.  
  640.     val( STRINGEXPR | EXPR )
  641.  
  642.         Value of the expression contained in a STRINGEXPR or
  643.         EXPR.  STRINGEXPR may be a string literal, variable,
  644.         function, or expression.
  645.         
  646.         For example, VAL("1 + sqr(4)") yields 3.
  647.  
  648.     asc( STRINGEXPR )
  649.  
  650.         Returns the ascii code for the first character of
  651.         STRINGEXPR.  A null string returns zero.
  652.  
  653.     instr(a$, b$ { , VAL } )
  654.  
  655.         Returns the position of the substring b$ in the
  656.         string a$ or returns a zero if b$ is not a substring.
  657.         VAL is an optional starting position in a$
  658.  
  659.     ubound ( VAR )
  660.     
  661.         If VAR is a dimensioned array, returns the maximum
  662.         legal subscript of the first dimension of that array,
  663.         else returns 0.
  664.  
  665.     fgetbyte ( FILENUM )
  666.  
  667.         Reads one byte from the open file specified by FILENUM
  668.         and returns an unsigned numeric value [0..255].
  669.  
  670.     eof(FILENUM)
  671.  
  672.         Returns true if the the last INPUT statement, INPUT$
  673.         or FGETBYTE function call which referenced the text
  674.         file specified by FILENUM tried to read past the end
  675.         of file. (Note that reading the last line of a file
  676.         will not read past the eof mark.  A subsequent read is
  677.         needed to set the EOF flag to true.  Reading past the
  678.         end-of-file will not report an error.)
  679.  
  680.     pop
  681.  
  682.         POP function (see also POP statement). Pops one variable
  683.         value off the stack and returns that value (string or
  684.         numeric).
  685.         
  686.         (POP can be used as either a statement (with a
  687.         parameter) or a function (no parameter). Note that the
  688.         POP function, unlike the POP statement, does not
  689.         restore the value of the variable pushed, but only
  690.         returns the pushed value.  This use of the POP
  691.         statement is different from the Applesoft usage.)
  692.  
  693.     peek( ADDR { , SIZE_VAL } )
  694.  
  695.         Returns the value of the byte in memory at address ADDR.
  696.         If SIZE_VAL is 2 or 4, returns the value of the 16-bit
  697.         or 32-bit word respectively (if correctly aligned).
  698.         If SIZE_VAL is 8, returns the value of the numeric
  699.         variable located at ADDR.  (peek(varptr(x),8) == x)
  700.  
  701.     varptr( VAR | STRINGVAR )
  702.     
  703.         Returns the memory address of a variable.
  704.     
  705.     erl
  706.  
  707.         Returns the line number of the last error.  Zero if the
  708.         error was in immediate mode.  The variable errorstatus$
  709.         gives the error type.
  710.  
  711.     timer
  712.  
  713.         Returns a numeric value of elapsed of seconds from the
  714.         computers internal clock.
  715.  
  716.     
  717.     STRING FUNCTIONS
  718.     
  719.     x$ + y$
  720.  
  721.         String concatenation.
  722.     
  723.         String concatenation (and the MID$, LEN and INSTR
  724.         functions) can handle strings of up to 32766 characters
  725.         in length (if the memory available to the program
  726.         permits).
  727.  
  728.     chr$(VAL)
  729.  
  730.         Returns the ascii character corresponding to the value
  731.         of VAL.
  732.  
  733.     str$( VAL { , EXPR } )
  734.  
  735.         Returns a string representation corresponding to VAL.
  736.         If EXPR is present then the string is padded to that
  737.         length.
  738.  
  739.     format$( VAL , STREXPR )
  740.  
  741.         Returns the string representation of VAL formatted
  742.         according to the format string STREXPR. The format
  743.         string STREXPR uses the same formatting syntax as the
  744.         PRINT USING statement.
  745.         
  746.     inkey$
  747.  
  748.         Return one character from the keyboard if input is
  749.         available. Returns a zero length string { "" } if no
  750.         keyboard input is available.  Non-blocking.  Can be
  751.         used for keyboard polling.
  752.  
  753.     input$( EXPR { , FILENUM } )
  754.  
  755.         Returns EXPR characters from file FILENUM. If f is not
  756.         present then get input from the console keyboard.
  757.  
  758.     mid$( a$, i { , j } )
  759.  
  760.         Returns a substring of a$ starting at the i'th
  761.         positions and j characters in length. If the second
  762.         parameter is not specified then the substring is
  763.         taken from the start position to the end of a$.
  764.  
  765.     right$(a$, EXPR )
  766.  
  767.         Returns the right EXPR characters of a$.
  768.  
  769.     left$(a$, EXPR )
  770.  
  771.         Returns the left EXPR characters of a$.
  772.  
  773.     field$( STRINGVAL, VAL { , STRINGVAL } )
  774.  
  775.         Returns the N-th field of the first string.  If the
  776.         optional string is present then use the first character
  777.         of that string as the field separator.  The default
  778.         separator is a space.  Similar to UNIX 'awk' fields.
  779.         
  780.         e.g.  field$("1 22 333 4", 3)  returns  "333"
  781.         
  782.         If VAL is -1 then returns a string with a length
  783.         equal to the number of seperators in the first string.
  784.  
  785.     hex$( VAL { , EXPR } )
  786.     bin$( VAL { , EXPR } )
  787.  
  788.         Returns the hexadecimal or binary string representation
  789.         corresponding to VAL.  If EXPR is present then the
  790.         string is padded with zeros to make it that length.
  791.  
  792.     lcase$( STRINGVAL )
  793.  
  794.         Returns STRINGVAL in all lower case characters.
  795.  
  796.     errorstatus$
  797.  
  798.         Returns the error message for the last error.
  799.  
  800.  
  801.     OPERATORS
  802.  
  803.     The following math operators  are available:
  804.  
  805.         ^    exponentiation
  806.         *    multiplication
  807.         /    division
  808.         mod    remainder
  809.         +    addition
  810.         -    subtraction
  811.  
  812.     logical operators: (any non-zero value is true)
  813.  
  814.             not    logical not
  815.  
  816.     bitwise operators:
  817.  
  818.             and    bitwise and
  819.             or    bitwise or
  820.             xor    bitwise exclusive-or
  821.  
  822.     comparison operators:
  823.  
  824.             <=    less than or equal
  825.             <>    not equal to
  826.             >=    greater than or equal
  827.             =    equal
  828.             >    greater than
  829.             <    less than
  830.  
  831.     x$=y$, x$<y$, x$>y$, x$<=y$, x$>=y$, x$<>y$
  832.  
  833.         String comparisons; result is 1 if true, 0 if false.
  834.         
  835.     Operator precedence (highest to lowest):
  836.  
  837.         ( )
  838.         -{unary_minus}  functions
  839.         ^
  840.         * / mod
  841.         + -
  842.         = < > <= >= <>
  843.         not
  844.         and
  845.         or xor
  846.  
  847.     
  848.     UNIX functions:
  849.  
  850.     sys( STRINGVAL )
  851.  
  852.         UNIX system call.  The string parameter is given to
  853.         the shell as a command.  Returns exit status.
  854.  
  855.     getenv$( STRINGVAL )
  856.          
  857.         Returns value for environment name STRINGVAL.
  858.               
  859.     argv$
  860.         Returns the UNIX shell command line arguments.
  861.  
  862.  
  863.     Macintosh commands:
  864.  
  865.     *** NOTE ***
  866.     
  867.         Many MacOS specific functions and commands are only
  868.         documented in the Chipmunk Basic quick reference file.
  869.  
  870.     gotoxy VAL, VAL
  871.  
  872.         Set the horizontal and vertical location of the
  873.         text output cursor.  (0,0) is the upper left corner.
  874.  
  875.     moveto VAL, VAL
  876.  
  877.         Sets the (x,y) location of the graphics pen.
  878.  
  879.     lineto VAL, VAL
  880.  
  881.         Draws a line from the current pen location to location
  882.         (x,y) in the graphics window.
  883.  
  884.     window x, y, char_cols, char_lines
  885.  
  886.         Change the text console window position and size.
  887.  
  888.     morse STRINGVAL { , VAL, VAL, VAL, VAL }
  889.  
  890.         Plays morse code through the speaker.
  891.         The parameters are: dot-speed-wpm, volume{0..100},
  892.         word-speed-wpm, frequency{in Hz or cps}
  893.  
  894.     sound VAL, VAL, VAL 
  895.  
  896.         The parameters are:
  897.         frequency{in Hz}, seconds_duration, volume{0..100}
  898.     
  899.     say STRINGVAL
  900.  
  901.         Speaks STRINGVAL if the Speech Manager Extension is
  902.         resident.  Try "say a$,200,46,1" for faster speech.
  903.  
  904.     open "SFGetFile" for input  as #FNUM
  905.     open "SFPutFile" for output as #FNUM
  906.  
  907.         Puts up a standard file dialog for the file name.
  908.  
  909.     files { STRINGVAL }
  910.     
  911.         Displays a listing of files in the named or current
  912.         directory.
  913.     
  914.     Macintosh functions:
  915.     
  916.     fre
  917.         Returns the amount of memory left for program use. 
  918.     
  919.     date$
  920.         Returns a string corresponding to the current date.
  921.  
  922.     time$
  923.         Returns a string corresponding to the current time.
  924.  
  925.     pos(VAL)
  926.  
  927.         Returns the horizontal position of the text cursor.
  928.         If VAL is negative returns the vertical position.
  929.     
  930.     errorstatus$
  931.     
  932.         Also returns the full path name of the program and
  933.         files opened by SFGetFile. (under System 7 and only
  934.         if the name fits in a string variable)
  935.     
  936.     
  937.     Macintosh menu items:
  938.  
  939.     Open or <cmd>O     will put up a dialog to allow selection
  940.             of a program file to load.  Basic Program
  941.             file names must end with a ".bas" suffix.
  942.  
  943.     Copy        will allow copying picts from the graphics
  944.             window.
  945.     
  946.     <cmd>.         Command-period will stop program execution.
  947.  
  948.     Print        Print graphics window if it's the frontmost
  949.             window. Only the graphics window can be printed.
  950.  
  951.  
  952.     RESERVED WORDS AND SYMBOLS
  953.  
  954.     + - * / ^ mod  and or xor not  > < >= <= <> = ()
  955.     sqr log exp sin cos tan atn  pi
  956.     abs sgn int rnd peek val asc len
  957.     mid$ right$ left$ str$ chr$  lcase$ ucase$
  958.     goto  if then else endif  gosub return
  959.     for to step next  while wend  select case
  960.     rem  let  dim erase  data read restore   field$
  961.     input print open for output append as close# load save
  962.     random lof loc get put   
  963.     inkey$  input$ eof  files  fgetbyte# fseek# fputbyte
  964.     run stop end exit quit cont  renum  new clear
  965.     date$ time$ timer  sound morse say  doevents
  966.     home cls gotoxy htab vtab pos 
  967.     graphics sprite pset moveto lineto window scrn mouse
  968.     varptr peek poke fre push pop  isarray
  969.     sub call usr  def fn
  970.     type class extends  string integer single double
  971.     asin acos sinh cosh tanh log10 floor true false ubound
  972.     
  973.     eqv imp  static  option degrees radians redim
  974.     msgbox  do loop until break
  975.     method private public local   menu dialog memstat()
  976.     draw play  bload bsave  min max mat
  977.     each  resume  function
  978.     key is each set width swap
  979.     
  980.  
  981.     CONVENTIONS
  982.  
  983.     EXPR        an expression that evaluates to a numeric value.
  984.     STRINGEXPR    a string expression.
  985.     VAR        a numeric variable.
  986.     STRINGVAR    a string variable. Name must end with a "$".
  987.     INTEGERVAR    a 16-bit variable. Name must end with a "%".
  988.     
  989.     All program lines must begin with a line number.
  990.     Using spaces (indentation) between the line number and
  991.     program statements is legal.  Line numbers can be
  992.     between 1 and 2147483647.  Programs lines must be no
  993.     longer than 254 characters in length.
  994.     
  995.     Subroutine names starting with "fn" are reserved for the
  996.     (obsolete) def fn functions.
  997.     
  998.     Hexadecimal numbers can be entered by preceding them with
  999.     a "0x" as in 0x02ae, or by "&h" as in &h0172.
  1000.     
  1001.     Multiple statements may be given on one line, separated by
  1002.     colons:
  1003.  
  1004.         10 INPUT X : PRINT X : STOP
  1005.  
  1006.  
  1007.     DIAGNOSTICS
  1008.  
  1009.     Some errors can be caught by the user program using the
  1010.     "on error goto" command. If no error trapping routine has been
  1011.     supplied then program execution is terminated and a message is
  1012.     printed with the corresponding line number.
  1013.  
  1014.     Graphics (MacOS) may require that the preferred memory
  1015.     requirements be increased using the Finder "Get Info" dialog
  1016.     box.
  1017.  
  1018.  
  1019.     CHANGES
  1020.     
  1021.      v3.4.7    - lower precedence of NOT operator
  1022.          - disabled ON GOTO range checking
  1023.      v3.4.6    - added MAT matrix statements
  1024.      v3.4.0    - OPEN ELSE added
  1025.      v3.3.4    - changed integer conversion to rounding
  1026.          - changed sub return values to: sub_name = x
  1027.          - added reserved words for: true false
  1028.      v3.3.3  - added acos, tanh, log10
  1029.      v3.2.8    - added class definitions
  1030.      
  1031.      Many others ...
  1032.  
  1033.     BUGS
  1034.  
  1035.     Many.  Perhaps competitive with African swamps.
  1036.     
  1037.     Integer variables (like i%) won't work as indexes in FOR-NEXT
  1038.     statements. Integer arrays can only have a dimension of one
  1039.     and will only work in assignment (LET) statements.  All
  1040.     arithmetic on integer variables is done using floating point
  1041.     arithmetic.  DIM AS DOUBLE and DIM AS INTEGER statements
  1042.     are ignored.
  1043.     
  1044.     Many string functions (except +, MID$, LEN and INSTR) silently
  1045.     truncate their results to 254 characters (e.g. without
  1046.     warning). All string function may silently truncate strings
  1047.     longer than 32766 characters. Any operation on strings longer
  1048.     than 254 characters will cause the program to run slower.
  1049.     
  1050.     Comments starting with ' sometimes can't be used after
  1051.     statements that can end with a string parameter. ( : '
  1052.     should always work.)
  1053.     
  1054.     Any variables used as a CLASS, or TYPE, globally overide all
  1055.     local variables of the same names.  Named SUBroutines are
  1056.     slower than GOSUBs. The combined length of a SUBroutine name
  1057.     and any local variables declared STATIC must be less than 29
  1058.     characters.
  1059.     
  1060.     Can't CONTinue from an error inside a named SUB subroutine.
  1061.     
  1062.     The PRINT USING format string doesn't recognize comma's,
  1063.     underscores and many other common format characters.
  1064.     
  1065.     Macintosh screen editing will only recognise the last line
  1066.     modified before a RETURN or ENTER key.  The EDIT command and
  1067.     Mac screen editing are incompatible.
  1068.  
  1069.     There are many undocumented graphics and sprite commands
  1070.     and keywords in the Macintosh port.  See the accompanying
  1071.     README and Chipmunk Basic quick-reference file.
  1072.     
  1073.  
  1074.     DISCLAIMER
  1075.  
  1076.     There is no warranty that this document is accurate.
  1077.  
  1078.     AUTHORS
  1079.     
  1080.     David Gillespie wrote basic.p 1.0 and the p2c lib.
  1081.     Ron Nicholson (rhn@nicholson.com) added file i/o, graphics
  1082.     and did the Unix, Macintosh and PowerMac port. (1990-1996Jul)
  1083.  
  1084.     Portions of this document are Copyright (C) 1989 Dave Gillespie.
  1085.     Copyright (C)1994,1996 Ronald H. Nicholson, Jr. (rhn@nicholson.com),
  1086.     All rights reserved.
  1087.     "Applesoft" is a trademark of Apple Computer, Inc., etc.
  1088.  
  1089. </PRE>
  1090. </BODY>
  1091. </HTML>
  1092.